//
//  JGTabBarController.m
//  JGRider
//
//  Created by 单启志 on 2018/1/25.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGTabBarController.h"
#import "JGNavigationController.h"

#import "JGHomeController.h" //首页
#import "JGHistoryOrderController.h" //历史订单
#import "JGMeController.h" //我的
@interface JGTabBarController ()<UITabBarControllerDelegate>

@end

@implementation JGTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tabBar.tintColor = MainColor;
    [self setValue:[NSValue valueWithUIOffset:UIOffsetMake(0, -3)] forKeyPath:FQKeyPath(self, titlePositionAdjustment)];

    [self addTabbarItems];
    [self addChildViewControllers];
    self.delegate=self;

}


-(void)addTabbarItems{

    NSDictionary *homeTabbarAttr=@{CYLTabBarItemTitle:@"实时订单",CYLTabBarItemImage:@"tab_icon_now_off",CYLTabBarItemSelectedImage:@"tab_icon_now_on"};
     NSDictionary *historyTabbarAttr=@{CYLTabBarItemTitle:@"历史订单",CYLTabBarItemImage:@"tab_icon_history_off",CYLTabBarItemSelectedImage:@"tab_icon_history_on"};
     NSDictionary *meTabbarAttr=@{CYLTabBarItemTitle:@"我的",CYLTabBarItemImage:@"tab_icon_mine_off",CYLTabBarItemSelectedImage:@"tab_icon_mine_on"};

    self.tabBarItemsAttributes=@[homeTabbarAttr,historyTabbarAttr,meTabbarAttr];
}

-(void)addChildViewControllers{
    JGNavigationController *homeNav=[[JGNavigationController alloc]initWithRootViewController:[[JGHomeController alloc]init]];
    JGNavigationController *historyNav=[[JGNavigationController alloc]initWithRootViewController:[[JGHistoryOrderController alloc]init]];
    JGNavigationController *meNav=[[JGNavigationController alloc]initWithRootViewController:[[JGMeController alloc]init]];

    self.viewControllers=@[homeNav,historyNav,meNav];
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}



@end
